from appium import webdriver
from appium.options.common import AppiumOptions

from appium.webdriver.common.appiumby import AppiumBy


class TestApiDemoOS:

    def setup_class(self):
        self.options = AppiumOptions()
        self.options.load_capabilities(
            {
                "platformName": "android",
                "appium:automationName": "uiautomator2",
                "appium:ensureWebviewsHavePages": True,
                "appium:nativeWebScreenshot": True,
                "appium:newCommandTimeout": 3600,
                "appium:connectHardwareKeyboard": True
            }
        )

        self.driver = webdriver.Remote("http://127.0.0.1:4723", options=self.options)

    def test_os(self):
        el1 = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="OS")
        # el1 = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="OS")
        el1.click()
        el2 = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="Morse Code")
        el2.click()
        el3 = self.driver.find_element(by=AppiumBy.ID, value="io.appium.android.apis:id/text")
        el3.send_keys("Zjy")
